package collection;

import collection.list.MyLinkedList;
import java.util.LinkedList;

/**
 * @Author Antony
 * @Since 2018/6/20 22:01
 */
public class CollectionMain {

    public static void main(String[] args) {
        testFIFOQueue();
        testLinkedList();
    }


    /**
     * 测试两个栈构成的 FIFO 队列
     */
    private static void testFIFOQueue(){
        FIFOQueue fifoQueue = new FIFOQueue();
        fifoQueue.put("A");
        fifoQueue.put("B");
        fifoQueue.put("C");
        fifoQueue.put("D");
        System.out.println(fifoQueue.size());
        System.out.println(fifoQueue.take());
        System.out.println(fifoQueue.take());

        System.out.println(fifoQueue.size());

        System.out.println(fifoQueue.take());
        System.out.println(fifoQueue.take());
    }


    /**
     * 测试自定义双链表相关操作
     */
    private static void testLinkedList(){
        // JDK 双链表
        LinkedList list = new LinkedList();
        list.add(1);
        list.add(2);
        list.add(3);
        list.isEmpty();
        list.iterator();
        System.out.println(list.toString());

        //自定义双链表
        MyLinkedList myLink = new MyLinkedList();
        myLink.add(1);
        myLink.add(2);
        myLink.add(3);
        myLink.add(4);
        System.out.println(myLink.size());
        System.out.println(myLink.toString());

        myLink.reverse();
        System.out.println(myLink.toString());
    }
}
